package main

import (
	"context"
	"dubbo.apache.org/dubbo-go/v3/common/logger"
	"dubbo.apache.org/dubbo-go/v3/config"
	_ "dubbo.apache.org/dubbo-go/v3/imports"
	"go-consumer/api"
	"time"
)

// 引入生成的接口结构
var helloServiceImpl = new(api.HelloServiceClientImpl)

// export DUBBO_GO_CONFIG_PATH=dubbogo.yml
func main() {
	config.SetConsumerService(helloServiceImpl)
	if err := config.Load(); err != nil {
		panic(err)
	}
	time.Sleep(3 * time.Second)

	logger.Info("start to test dubbo")
	req := &api.HelloRequest{
		Name: "zhouyu",
	}
	reply, err := helloServiceImpl.SayHello(context.Background(), req)
	if err != nil {
		logger.Error(err)
	}
	logger.Infof("client response result: %v\n", reply)
}
